package day04;

public class test4 {
    public static void main(String[] args) {
        A a = new A();
        // 有名字的实现类
        MyInterA m = new MyInterA();
        a.methodA(m);
        // 匿名内部类
        InterA i = new InterA(){
            public void showA(){
                System.out.println("匿名内部类");
            }
        };
        a.methodA(i);
        // lambda
        InterA ii = ()-> System.out.println("匿名内部类");
        a.methodA(ii);
    }
}
    //定义接口
    interface InterA {
    void showA();
}
    class A {
        public void methodA(InterA a) {
            a.showA();
        }
    }

    class MyInterA implements InterA
    {
        public void showA(){
            System.out.println(("MyInterA"));
        }
    }

